import request from '../utils/request'
/**
 * 参数列表
 * @param {*} id
 * @param {*} sel
 * @returns
 */
export const getparamsList = (id, sel) => {
  return request({
    url: `categories/${id}/attributes`,
    method: 'GET',
    params: {
      sel: sel
    }
  })
}

export const getGoodList = () => {
  return request({
    url: 'categories',
    method: 'GET'
  })
}
/**
 * 添加动态参数或者静态属性
 * @param {*} id
 * @param {*} sel
 * @param {*} name
 * @param {*} val
 * @returns
 */
export const changeParamsList = (id, sel, name, val) => {
  return request({
    url: `categories/${id}/attributes`,
    method: 'POST',
    data: {
      attr_sel: sel,
      attr_name: name,
      attr_vals: val
    }
  })
}

/**
 * 编辑提交参数
 * @param {*} id
 * @param {*} attrId
 * @param {*} data
 * @returns
 */
export const editparams = (id, attrId, data) => {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'put',
    data
  })
}
/**
 * 删除参数
 * @param {*} id
 * @param {*} attrId
 * @returns
 */
export const delparams = (id, attrId) => {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'delete'
  })
}

/**
 *商品分类列表数据
 * @param {*} params
 * @returns
 */
export const getGoods = (params) => {
  return request({
    url: 'categories',
    method: 'GET',
    params
  })
}
// 添加分类
export const addparams = (data) => {
  return request({
    url: 'categories',
    method: 'POST',
    data
  })
}

/**
 * 删除分类
 * @param {*} id
 * @returns
 */
export const delFl = (id) => {
  return request({
    url: 'categories/' + id,
    method: 'delete'
  })
}
// 编辑分类
export const editFl = (id, name) => {
  return request({
    url: 'categories/' + id,
    method: 'put',
    data: {
      cat_name: name
    }
  })
}
